/*
 * MAlice.hpp
 *
 *  Created on: 30 Oct 2010
 *      Author: kn308
 */

#ifndef MALICE_HPP_
#define MALICE_HPP_

#include <string>
#include <stdexcept>

#include <climits>
#include <cstdint>

#include <llvm/DerivedTypes.h>
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/Analysis/Verifier.h>
#include <llvm/Support/IRBuilder.h>

#define MALICE_ASSERT(type, expr, msg) \
	::MAlice::assert##type(!!expr, __FILE__, __LINE__, msg)

namespace std
{
	namespace tr1 {}
}

using namespace std;
using namespace std::tr1;

using namespace llvm;

namespace MAlice
{

void assertTrue(bool expr, const char* file, int line, const std::string& msg);

template<class T>
T* assertNotNull(T* t, const char* file, int line, const std::string& msg)
{
	assertTrue(t != NULL, file, line, msg);
	return t;
}

template<class T, class U>
void assertEqual(const T& t, const U& u, const char* file, int line,
		const std::string& msg)
{
	assertTrue(t == u, file, line, msg);
}

template<class T, class U>
void assertNotEqual(const T& t, const U& u, const char* file, int line,
		const std::string& msg)
{
	assertTrue(t != u, file, line, msg);
}

}

#endif /* MALICE_HPP_ */
